package com.lyf.task.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.lyf.task.result.rfidResult;
import com.lyf.task.service.RFIDUtilService;

@Controller
public class RFIDController {
	
	@Autowired
	private RFIDUtilService rfidUtilServiceImpl;
	
	
	@RequestMapping("readAndWrite.html")
	public String readAndWrite(){return "readAndWrite";}
	
	@RequestMapping("read.html")
	public String read(Model model){
		
		model.addAttribute("result",rfidUtilServiceImpl.read());
	
		return "readAndWrite";
	}
	
	@RequestMapping("write.html")
	public String write(Model model,int pid,String tradeTime,int tradeTimes,int degree){
		
		System.out.println();
		rfidResult  rs = new rfidResult(pid,tradeTime,tradeTimes,degree);
		
		rfidUtilServiceImpl.writeNewRfid(rs);
	
		model.addAttribute("result",rs);
		return "readAndWrite";
	}
}
